home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 587 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: clamage@Eng.Sun.COM (Steve Clamage)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Namespaces within class definition???
  5. Date: 28 Feb 1996 13:14:30 PST
  6. Organization: Sun Microsystems Inc.
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4h2ajf$l69@engnews1.Eng.Sun.COM>
  9. References: <4h27pi$ejv@nnrp1.news.primenet.com>
  10. Reply-To: clamage@Eng.Sun.COM
  11. NNTP-Posting-Host: isolde.mti.sgi.com
  12. X-Original-Date: 28 Feb 1996 19:31:59 GMT
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMTTFw0y4NqrwXLNJAQH9HAH9GallI88vMb6cluzZxMM5qVbsV86WkixI
  15.     mmvUCKT9oaIgwsXXiHdnVX/pJ+pXj3fbbovUvkjkuPQ5aiJ4CpTMrw==
  16.     =QfRz
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. In article ejv@nnrp1.news.primenet.com, kj7bg@primenet.com (Bob White) writes:
  20.  
  21. >Assuming that the "string" class is properly defined in namespace "std", is it 
  22. >legal to do the following:
  23.  
  24. >class xyz : public std::string {
  25. >}
  26.  
  27. >I am trying to do this with Visual C++ v4.0 and it is giving me an INTERNAL 
  28. >COMPILER ERROR.  I thought that this was legal syntax, but am not certain.
  29. >Thanks in advance for your help.
  30.  
  31. Yes, it's valid. Sounds like growing pains regarding a new language feature.
  32.  
  33. Try this as a workaround:
  34.  
  35.     using std::string;
  36.     class xyz : public string { ...    };
  37.  
  38. The difference is that std::string is now placed in the current scope 
  39. as "string", which might collide with other names in the program.
  40. Ideally, you will abandon "string" as a user identifier because it is
  41. the name of a standard class. Using "string" for other purposes
  42. will be confusing and make future maintenance more difficult.
  43. ---
  44. Steve Clamage, stephen.clamage@eng.sun.com
  45. ---
  46. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  47.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  48.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  49.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  50.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  51. ]
  52.